function unique(arr = []) {
  const res = [];

  return arr.filter((element) => {
    if (res.indexOf(element) >= 0) {
      return false;
    } else {
      res.push(element);

      return true;
    }
  });
}

function unique1(arr) {
  let set = new Set();

  arr.forEach((element) => {
    if (set.has(element)) {
      return;
    } else {
      set.add(element);
    }
  });

  return [...set];
}

console.log(unique1([2, 2, 3, 4, 6, 6, 7, 8, 8]));
